package com.common.dao.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.datanucleus.jpa.PersistenceProviderImpl;

public final class EntityFactory {
	
	private static final EntityManagerFactory ENTITY_MANAGER = Persistence.
			createEntityManagerFactory("transactions-optional");

	private EntityFactory() {}
	
	public static EntityManagerFactory getInstance() {
		PersistenceProviderImpl p = new PersistenceProviderImpl();
		return p.createEntityManagerFactory("transactions-optional", null);
	}
	
	public static EntityManager getEntityManager() {
		return ENTITY_MANAGER.createEntityManager();
	}
}
